Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/coreclr/inc/readytorun.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// If you update this, ensure you run `git grep MINIMUM_READYTORUN_MAJOR_VERSION`
// and handle pending work.
#define READYTORUN_MAJOR_VERSION 26
#define READYTORUN_MINOR_VERSION 0x0001
#define READYTORUN_MINOR_VERSION 0x0002

#define MINIMUM_READYTORUN_MAJOR_VERSION 26

Expand Down Expand Up @@ -67,6 +67,7 @@
// R2R Version 25 renames runtime async infrastructure members, makes thunk-used members NonVersionable, and frees up a flag in CorInfoContinuationFlags
// R2R Version 26 changes ARM64 NativeVarInfo register encoding to include V0-V31
// R2R Version 26.1 adds READYTORUN_FIXUP_StoreMultiCallableAddrOfCode for storing a method's MultiCallableAddrOfCode into a location in the R2R image (used on WebAssembly)
// R2R Version 26.2 adds READYTORUN_HELPER_GetRuntimeTypeHandleMaybeNull

struct READYTORUN_CORE_HEADER
{
Expand Down Expand Up @@ -403,6 +404,7 @@ enum ReadyToRunHelper
READYTORUN_HELPER_GetRuntimeTypeHandle = 0x54,
READYTORUN_HELPER_GetRuntimeMethodHandle = 0x55,
READYTORUN_HELPER_GetRuntimeFieldHandle = 0x56,
READYTORUN_HELPER_GetRuntimeTypeHandleMaybeNull = 0x57,

READYTORUN_HELPER_Box = 0x58,
READYTORUN_HELPER_Box_Nullable = 0x59,
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/inc/readytorunhelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ HELPER(READYTORUN_HELPER_MemCpy, CORINFO_HELP_MEMCPY,
HELPER(READYTORUN_HELPER_GetRuntimeTypeHandle, CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE, )
HELPER(READYTORUN_HELPER_GetRuntimeMethodHandle, CORINFO_HELP_METHODDESC_TO_STUBRUNTIMEMETHOD, )
HELPER(READYTORUN_HELPER_GetRuntimeFieldHandle, CORINFO_HELP_FIELDDESC_TO_STUBRUNTIMEFIELD, )
HELPER(READYTORUN_HELPER_GetRuntimeTypeHandleMaybeNull, CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL, )

HELPER(READYTORUN_HELPER_Box, CORINFO_HELP_BOX, )
HELPER(READYTORUN_HELPER_Box_Nullable, CORINFO_HELP_BOX_NULLABLE, )
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/nativeaot/Runtime/inc/ModuleHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct ReadyToRunHeaderConstants
static const uint32_t Signature = 0x00525452; // 'RTR'

static const uint32_t CurrentMajorVersion = 26;
static const uint32_t CurrentMinorVersion = 1;
static const uint32_t CurrentMinorVersion = 2;
};

struct ReadyToRunHeader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal struct ReadyToRunHeaderConstants
public const uint Signature = 0x00525452; // 'RTR'

public const ushort CurrentMajorVersion = 26;
public const ushort CurrentMinorVersion = 1;
public const ushort CurrentMinorVersion = 2;
}
#if READYTORUN
#pragma warning disable 0169
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ public enum ReadyToRunHelper
GetRuntimeTypeHandle = 0x54,
GetRuntimeMethodHandle = 0x55,
GetRuntimeFieldHandle = 0x56,
GetRuntimeTypeHandleMaybeNull = 0x57,

Box = 0x58,
Box_Nullable = 0x59,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ static void Validate(ReadyToRunReader reader)
List<ReadyToRunMethod> methods = R2RAssert.GetAllMethods(reader);
Assert.True(methods.Exists(method =>
method.SignatureString.Contains("AddIntegers", StringComparison.Ordinal)));
Assert.True(R2RAssert.HasCompiledMethod(
reader,
"Webcil.WasmWebcilModule",
"GetTypedReferenceType",
out string typedReferenceDiagnostic), typedReferenceDiagnostic);
// Reads static data, so the JIT materializes the image base via a well-known-global global.get.
Assert.True(methods.Exists(method =>
method.SignatureString.Contains("SumStaticData", StringComparison.Ordinal)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public static int AddIntegers(int left, int right)
return left + right;
}

public static Type GetTypedReferenceType(TypedReference value)
{
return __reftype(value);
}

// Reads static data, which forces the JIT to materialize the imageBase address via a
// 'global.get' of the wasm imageBase well-known global.
public static int SumStaticData(int index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,10 @@ private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum)
case CorInfoHelpFunc.CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE:
id = ReadyToRunHelper.GetRuntimeTypeHandle;
break;
case CorInfoHelpFunc.CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL:
case CorInfoHelpFunc.CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE_MAYBENULL:
id = ReadyToRunHelper.GetRuntimeTypeHandleMaybeNull;
break;

case CorInfoHelpFunc.CORINFO_HELP_ISINSTANCEOF_EXCEPTION:
id = ReadyToRunHelper.IsInstanceOfException;
Expand Down Expand Up @@ -1328,8 +1332,6 @@ private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum)

case CorInfoHelpFunc.CORINFO_HELP_GETSYNCFROMCLASSHANDLE:
case CorInfoHelpFunc.CORINFO_HELP_GETCLASSFROMMETHODPARAM:
case CorInfoHelpFunc.CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL:
case CorInfoHelpFunc.CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE_MAYBENULL:
case CorInfoHelpFunc.CORINFO_HELP_GETREFANY:
case CorInfoHelpFunc.CORINFO_HELP_NEW_MDARR_RARE:
// For x86 tailcall where helper is required we need runtime JIT.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1817,6 +1817,10 @@ private void ParseHelper(StringBuilder builder)
builder.Append("GET_RUNTIME_TYPE_HANDLE");
break;

case ReadyToRunHelper.GetRuntimeTypeHandleMaybeNull:
builder.Append("GET_RUNTIME_TYPE_HANDLE_MAYBENULL");
break;

case ReadyToRunHelper.GetRuntimeMethodHandle:
builder.Append("GET_RUNTIME_METHOD_HANDLE");
break;
Expand Down
37 changes: 36 additions & 1 deletion src/tests/JIT/Directed/coverage/importer/refanytype1.il
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,51 @@ ldc.i4 100
ret
}
.class public auto ansi refanytype1 {
.method private static bool IsInt32(valuetype [mscorlib]System.RuntimeTypeHandle handle) noinlining
{
ldarga.s handle
ldtoken int32
call instance bool valuetype [mscorlib]System.RuntimeTypeHandle::Equals(valuetype [mscorlib]System.RuntimeTypeHandle)
ret
}
.method private static bool IsDefault(valuetype [mscorlib]System.RuntimeTypeHandle handle) noinlining
{
.locals init (valuetype [mscorlib]System.RuntimeTypeHandle defaultHandle)
ldarga.s handle
ldloc defaultHandle
call instance bool valuetype [mscorlib]System.RuntimeTypeHandle::Equals(valuetype [mscorlib]System.RuntimeTypeHandle)
ret
}
.method public static int32 Main()
{
.custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = (
01 00 00 00
)
.locals init (typedref empty)
.entrypoint
call int32 f()
mkrefany int32
refanytype
pop
call bool refanytype1::IsInt32(valuetype [mscorlib]System.RuntimeTypeHandle)
brtrue.s NON_NULL_PASS
ldc.i4.m1
ret
NON_NULL_PASS:
ldloc empty
refanytype
call bool refanytype1::IsDefault(valuetype [mscorlib]System.RuntimeTypeHandle)
brtrue.s RAW_NULL_PASS
ldc.i4.s -2
ret
RAW_NULL_PASS:
ldloc empty
// GetTargetType contains refanytype followed by Type.GetTypeFromHandle, which the importer
// fuses into CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL.
call class [mscorlib]System.Type [mscorlib]System.TypedReference::GetTargetType(typedref)
brfalse.s PASS
ldc.i4.s -3
ret
PASS:
ldc.i4 100
ret
}
Expand Down
Loading