Skip to content

Commit

Permalink
Add newguid.bat/sh to update jiteeversionguid.h (#88022)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo committed Jun 26, 2023
1 parent dc08e2b commit bc70fec
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/coreclr/tools/Common/JitInterface/ThunkGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Thunkerator
Expand Down Expand Up @@ -633,18 +634,51 @@ private static void SPMI_ShimSimple_ICorJitInfo(TextWriter tw, IEnumerable<Funct
wrappedObjectName: "original_ICorJitInfo");
}

private static void GenerateNewJitEEVersion(string file)
{
if (!File.Exists(file))
throw new FileNotFoundException(file);

Guid newGuid = Guid.NewGuid();
string[] hex = newGuid.ToString("X").Replace("{", "").Replace("}", "").Split(',');

string newGuidStr = $$"""
constexpr GUID JITEEVersionIdentifier = { /* {{newGuid:D}} */
{{hex[0]}},
{{hex[1]}},
{{hex[2]}},
{{{hex[3]}}, {{hex[4]}}, {{hex[5]}}, {{hex[6]}}, {{hex[7]}}, {{hex[8]}}, {{hex[9]}}, {{hex[10]}}}
};
""";
string pattern = @"constexpr GUID JITEEVersionIdentifier = .*\n.*\n.*\n.*\n.*\n.*;";
string output = Regex.Replace(File.ReadAllText(file), pattern, newGuidStr);
File.WriteAllText(file, output);
Console.WriteLine($"Updated to {newGuid}");
}

private static void Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("ThunkGenerator - Generate thunks for the jit interface and for defining the set of instruction sets supported by the runtime, JIT, and crossgen2. Call by using the gen scripts which are aware of the right set of files generated and command line args.");
return;
}
if (args[0] == "InstructionSetGenerator")

if (args[0] == "NewJITEEVersion")
{
if (args.Length != 2)
{
Console.WriteLine("Incorrect number of arguments specified for NewJITEEVersion");
return;
}
GenerateNewJitEEVersion(args[1]);
}
else if (args[0] == "InstructionSetGenerator")
{
if (args.Length != 7)
{
Console.WriteLine("Incorrect number of files specified for generation");
return;
}
InstructionSetGenerator generator = new InstructionSetGenerator();
if (!generator.ParseInput(new StreamReader(args[1])))
Expand Down Expand Up @@ -685,6 +719,7 @@ private static void Main(string[] args)
if (args.Length != 8)
{
Console.WriteLine("Incorrect number of files specified for generation");
return;
}

IEnumerable<FunctionDecl> functions = ParseInput(new StreamReader(args[0]));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pushd %~dp0
call ..\..\..\..\..\..\dotnet.cmd run -- ThunkInput.txt ..\CorInfoImpl_generated.cs ..\..\..\aot\jitinterface\jitinterface_generated.h ..\..\..\..\jit\ICorJitInfo_names_generated.h ..\..\..\..\jit\ICorJitInfo_wrapper_generated.hpp ..\..\..\..\inc\icorjitinfoimpl_generated.h ..\..\..\..\tools\superpmi\superpmi-shim-counter\icorjitinfo_generated.cpp ..\..\..\..\tools\superpmi\superpmi-shim-simple\icorjitinfo_generated.cpp
call ..\..\..\..\..\..\dotnet.cmd run -- InstructionSetGenerator InstructionSetDesc.txt ..\..\Internal\Runtime\ReadyToRunInstructionSet.cs ..\..\Internal\Runtime\ReadyToRunInstructionSetHelper.cs ..\CorInfoInstructionSet.cs ..\..\..\..\inc\corinfoinstructionset.h ..\..\..\..\inc\readytoruninstructionset.h
call ..\..\..\..\..\..\dotnet.cmd run -- NewJITEEVersion ..\..\..\..\inc\jiteeversionguid.h
popd
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
cd "$(dirname ${BASH_SOURCE[0]})"
../../../../../../dotnet.sh run -- ThunkInput.txt ../CorInfoImpl_generated.cs ../../../aot/jitinterface/jitinterface_generated.h ../../../../jit/ICorJitInfo_names_generated.h ../../../../jit/ICorJitInfo_wrapper_generated.hpp ../../../../inc/icorjitinfoimpl_generated.h ../../../../tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp ../../../../tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp
../../../../../../dotnet.sh run -- InstructionSetGenerator InstructionSetDesc.txt ../../Internal/Runtime/ReadyToRunInstructionSet.cs ../../Internal/Runtime/ReadyToRunInstructionSetHelper.cs ../CorInfoInstructionSet.cs ../../../../inc/corinfoinstructionset.h ../../../../inc/readytoruninstructionset.h
../../../../../../dotnet.sh run -- NewJITEEVersion ../../../../inc/jiteeversionguid.h

0 comments on commit bc70fec

Please sign in to comment.