Skip to content

Commit

Permalink
Update CoreCLR source to .NET8
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek committed Nov 28, 2023
1 parent f2048e8 commit 41f2f78
Show file tree
Hide file tree
Showing 121 changed files with 23,090 additions and 21,602 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
# Info

The files here were copied from
<https://github.com/dotnet/runtime/tree/v7.0.0/src/coreclr>.
<https://github.com/dotnet/runtime/tree/v8.0.0/src/coreclr>.

This is to allow using the runtime's Platform Adaptation Layer.

Manual changes:
in `\inc\corhlpr.cpp:L143`,
assert surrounded by `_DEBUG` conditional compilation

```cpp
+#ifdef _DEBUG
assert(&origBuff[size] == outBuff);
+#endif
```
in `pal\sal.h:2610` commented ouf `#define __valid`
```cpp
// #define __valid
```
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;

// The main application class containing the program entry point.
Expand All @@ -64,9 +64,9 @@ public static int Main()
{
// Calculate the filenames of the input and output files.
string inputFile = "CrstTypes.def";
string outputFile = "crsttypes.h";
string outputFile = "crsttypes_generated.h";

// A common error is to forget to check out the CrstTypes.h file first. Handle this case specially
// A common error is to forget to check out the crsttypes_generated.h file first. Handle this case specially
// so we can give a good error message.
if (File.Exists(outputFile) && (File.GetAttributes(outputFile) & FileAttributes.ReadOnly) != 0)
{
Expand Down Expand Up @@ -113,7 +113,7 @@ public static int Main()
}
}

// Emit the CrstTypes.h output file.
// Emit the crsttypes_generated.h output file.
void WriteHeaderFile(string fileName)
{
FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
Expand Down Expand Up @@ -476,16 +476,16 @@ static bool Unleveled(CrstType crst)
class TypeFileParser
{
// Remember the input file name and the dictionary we're meant to populate.
string m_typeFileName;
Dictionary<string, CrstType> m_crsts;
string m_typeFileName;
Dictionary<string, CrstType> m_crsts;

// Compile regular expressions for detecting comments and tokens in the parser input.
Regex m_commentRegex = new Regex(@"//.*");
Regex m_tokenRegex = new Regex(@"^(\s*(\S+)\s*)*");
Regex m_commentRegex = new Regex(@"//.*");
Regex m_tokenRegex = new Regex(@"^(\s*(\S+)\s*)*");

// Input is lexed into an array of tokens. We record the index of the token being currently parsed.
Token[] m_tokens;
int m_currToken;
Token[] m_tokens;
int m_currToken;

// Parse the given file into Crst type definitions and place these definitions in the dictionary provided.
// Syntax errors are signalled via ParseError derived exceptions.
Expand Down Expand Up @@ -553,46 +553,46 @@ void ParseCrst()
switch (token.Id)
{

case KeywordId.AcquiredBefore:
// Simply parse the following list of Crst types into the current type's AcquiredBefore list.
ParseList(crst.AcquiredBeforeList);
break;

case KeywordId.AcquiredAfter:
// AcquiredAfter is trickier. To make the ranking algorithm's life easier we actually
// normalize all rules to the AcquiredBefore form (see LevelCrsts() for the reasoning). So we
// capture the list of Crst types that follow the AcquiredAfter keyword and then append the
// current type to the AcquiredBefore list of each type found.
list = new List<CrstType>();
ParseList(list);
foreach (CrstType priorCrst in list)
priorCrst.AcquiredBeforeList.Add(crst);
break;

case KeywordId.SameLevelAs:
// Parse the following list of Crst types them let the CrstTypeGroup class handle the
// resulting updates to the type groups we're currently maintaining. See the comments for the
// CrstTypeGroup class for more details.
list = new List<CrstType>();
ParseList(list);
foreach (CrstType sameLevelCrst in list)
CrstTypeGroup.Join(crst, sameLevelCrst);
break;

case KeywordId.Unordered:
crst.Level = CrstType.CrstUnordered;
break;

case KeywordId.End:
parsingCrst = false;
break;

default:
throw new UnexpectedTokenError(token,
KeywordId.AcquiredBefore,
KeywordId.AcquiredAfter,
KeywordId.SameLevelAs,
KeywordId.Unordered);
case KeywordId.AcquiredBefore:
// Simply parse the following list of Crst types into the current type's AcquiredBefore list.
ParseList(crst.AcquiredBeforeList);
break;

case KeywordId.AcquiredAfter:
// AcquiredAfter is trickier. To make the ranking algorithm's life easier we actually
// normalize all rules to the AcquiredBefore form (see LevelCrsts() for the reasoning). So we
// capture the list of Crst types that follow the AcquiredAfter keyword and then append the
// current type to the AcquiredBefore list of each type found.
list = new List<CrstType>();
ParseList(list);
foreach (CrstType priorCrst in list)
priorCrst.AcquiredBeforeList.Add(crst);
break;

case KeywordId.SameLevelAs:
// Parse the following list of Crst types them let the CrstTypeGroup class handle the
// resulting updates to the type groups we're currently maintaining. See the comments for the
// CrstTypeGroup class for more details.
list = new List<CrstType>();
ParseList(list);
foreach (CrstType sameLevelCrst in list)
CrstTypeGroup.Join(crst, sameLevelCrst);
break;

case KeywordId.Unordered:
crst.Level = CrstType.CrstUnordered;
break;

case KeywordId.End:
parsingCrst = false;
break;

default:
throw new UnexpectedTokenError(token,
KeywordId.AcquiredBefore,
KeywordId.AcquiredAfter,
KeywordId.SameLevelAs,
KeywordId.Unordered);
}
}
}
Expand Down Expand Up @@ -632,9 +632,9 @@ void ParseList(List<CrstType> list)
// Lex the input file into an array of tokens.
void InitTokenStream()
{
StreamReader file = new StreamReader(m_typeFileName);
int lineNumber = 1;
List<Token> tokenList = new List<Token>();
StreamReader file = new StreamReader(m_typeFileName);
int lineNumber = 1;
List<Token> tokenList = new List<Token>();

// Read the file a line at a time.
string line;
Expand Down Expand Up @@ -706,15 +706,15 @@ internal class Token
static Dictionary<string, KeywordId> s_keywords;

// The characters comprising the text of the token from the input file.
string m_text;
string m_text;

// Where the token was found (for error messages).
string m_file;
int m_line;
int m_column;
string m_file;
int m_line;
int m_column;

// The ID of the keyword this token represents (or KeywordId.Id).
KeywordId m_id;
KeywordId m_id;

// Static class initialization.
static Token()
Expand Down Expand Up @@ -747,9 +747,9 @@ public Token(string file, string text, int line, int column)
m_id = KeywordId.Id;
}

public string Text { get { return m_text; } }
public string Location { get { return String.Format("{0} line {1}, column {2}", m_file, m_line, m_column); } }
public KeywordId Id { get { return m_id; } }
public string Text {get { return m_text; }}
public string Location {get { return String.Format("{0} line {1}, column {2}", m_file, m_line, m_column); }}
public KeywordId Id {get { return m_id; }}
}

// Base class for all syntax errors reported by the parser.
Expand All @@ -758,12 +758,12 @@ internal class ParseError : Exception
// A raw error message.
public ParseError(string message)
: base(message)
{ }
{}

// An error message tagged with a file, line and column (coming from an error token).
public ParseError(string message, Token errorToken)
: base(String.Format("{0}: {1}", errorToken.Location, message))
{ }
{}

// Produce a textual name for the given keyword type.
protected static string IdToName(KeywordId id)
Expand All @@ -782,7 +782,7 @@ internal class UnexpectedTokenError : ParseError
// optionally the names of zero or more tokens that would have been accepted.
public UnexpectedTokenError(Token errorToken, params KeywordId[] expected)
: base(FormatErrorMessage(errorToken, expected))
{ }
{}

static string FormatErrorMessage(Token errorToken, KeywordId[] expected)
{
Expand Down Expand Up @@ -813,7 +813,7 @@ internal class UnexpectedEofError : ParseError
{
public UnexpectedEofError()
: base("Unexpected end of file")
{ }
{}
}
}

Expand All @@ -827,24 +827,24 @@ class CrstType : IComparable
public static readonly int CrstUnassigned = -2;

// Name of the type, e.g. "AppDomainCache" for the CrstAppDomainCache type.
string m_name;
string m_name;

// The numeric ranking assigned to this type. Starts as CrstUnassigned and then becomes either
// CrstUnordered (while parsing the input file) or a number >= 0 (during LevelCrsts()).
int m_level;
int m_level;

// List of Crst types that can be legally acquired while this one is held. (AcquiredAfter relationships
// are by switching the terms and adding to the second type's AcquiredBefore list).
List<CrstType> m_acquiredBeforeCrsts;
List<CrstType> m_acquiredBeforeCrsts;

// Either null if this Crst type is not in (or has not yet been determined to be in) a SameLevelAs
// relationship or points to a CrstTypeGroup that records all the sibling types at the same level (that
// have been discovered thus far during parsing).
CrstTypeGroup m_group;
CrstTypeGroup m_group;

// Set once a definition for this type has been discovered. Used to detect double definitions and types
// referenced without definitions.
bool m_defined;
bool m_defined;

public CrstType(string name)
{
Expand All @@ -855,11 +855,11 @@ public CrstType(string name)
m_defined = false;
}

public string Name { get { return m_name; } }
public int Level { get { return m_level; } set { m_level = value; } }
public List<CrstType> AcquiredBeforeList { get { return m_acquiredBeforeCrsts; } set { m_acquiredBeforeCrsts = value; } }
public CrstTypeGroup Group { get { return m_group; } set { m_group = value; } }
public bool Defined { get { return m_defined; } set { m_defined = value; } }
public string Name {get { return m_name; }}
public int Level {get { return m_level; } set { m_level = value; }}
public List<CrstType> AcquiredBeforeList {get { return m_acquiredBeforeCrsts; } set { m_acquiredBeforeCrsts = value; }}
public CrstTypeGroup Group {get { return m_group; } set { m_group = value; }}
public bool Defined {get {return m_defined; } set { m_defined = value; }}

// Helper used to sort CrstTypes. The sort order is lexical based on the type name.
public int CompareTo(object other)
Expand All @@ -882,10 +882,10 @@ public int CompareTo(object other)
class CrstTypeGroup
{
// We record every group that has been formed so far. This makes normalizing all groups easier.
static List<CrstTypeGroup> s_groups = new List<CrstTypeGroup>();
static List<CrstTypeGroup> s_groups = new List<CrstTypeGroup>();

// Crst types that are members of the current group. There are no duplicates in this list.
List<CrstType> m_members = new List<CrstType>();
List<CrstType> m_members = new List<CrstType>();

// Declare a SameLevelAs relationship between the two Crst types given. Groups will be assigned, created
// or merged as required to maintain our guarantees (each CrstType is a member of at most one group and
Expand Down Expand Up @@ -988,5 +988,5 @@ void NormalizeRules()
crst.AcquiredBeforeList = acquiredBeforeList.GetRange(0, acquiredBeforeList.Count);
}

public List<CrstType> Members { get { return m_members; } }
public List<CrstType> Members {get { return m_members; }}
}
Loading

0 comments on commit 41f2f78

Please sign in to comment.