Skip to content

Commit a752396

Browse files
committed
remove unused argument
1 parent 7a111b4 commit a752396

File tree

6 files changed

+62
-41
lines changed

6 files changed

+62
-41
lines changed

src/coreclr/nativeaot/Runtime/thread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ COOP_PINVOKE_HELPER(Object**, RhGetInlineThreadStaticStorage, ())
12871287
return pCurrentThread->GetInlineThreadStaticStorage();
12881288
}
12891289

1290-
COOP_PINVOKE_HELPER(Object*, RhpGetThreadStaticBaseForType, (void* unused, uint32_t typeIndex))
1290+
COOP_PINVOKE_HELPER(Object*, RhpGetThreadStaticBaseForType, (uint32_t typeIndex))
12911291
{
12921292
Thread* pCurrentThread = ThreadStore::RawGetCurrentThread();
12931293
Object* pInlineThreadStaticStorage = *pCurrentThread->GetInlineThreadStaticStorage();

src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public static unsafe object LoadPointerTypeFieldValueFromValueType(TypedReferenc
341341

342342
public static unsafe object GetThreadStaticBase(IntPtr cookie)
343343
{
344-
return ThreadStatics.GetThreadStaticBaseForType(*(TypeManagerSlot**)cookie, (int)*((IntPtr*)(cookie) + 1));
344+
return ThreadStatics.GetThreadStaticBaseForType((int)*((IntPtr*)(cookie) + 1), *(TypeManagerSlot**)cookie);
345345
}
346346

347347
public static int GetHighestStaticThreadStaticIndex(TypeManagerHandle typeManager)

src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/ThreadStatics.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ private static unsafe int GetInlineTlsLength(TypeManagerHandle typeManager)
3030
return length;
3131
}
3232

33-
private static unsafe bool IsInlineThreadStatic(TypeManagerSlot* pModuleData, int typeTlsIndex)
33+
private static unsafe bool IsInlineThreadStatic(int typeTlsIndex, TypeManagerSlot* pModuleData)
3434
{
3535
if (pModuleData->ModuleIndex != 0)
3636
return false;
@@ -42,9 +42,9 @@ private static unsafe bool IsInlineThreadStatic(TypeManagerSlot* pModuleData, in
4242
/// This method is called from a ReadyToRun helper to get base address of thread
4343
/// static storage for the given type.
4444
/// </summary>
45-
internal static unsafe object GetThreadStaticBaseForType(TypeManagerSlot* pModuleData, int typeTlsIndex)
45+
internal static unsafe object GetThreadStaticBaseForType(int typeTlsIndex, TypeManagerSlot* pModuleData)
4646
{
47-
if (!IsInlineThreadStatic(pModuleData, typeTlsIndex))
47+
if (!IsInlineThreadStatic(typeTlsIndex, pModuleData))
4848
return GetUninlinedThreadStaticBaseForType(pModuleData, typeTlsIndex);
4949

5050
ref object[] threadStorage = ref RuntimeImports.RhGetInlineThreadStaticStorage();

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/CompilerServices/ClassConstructorRunner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ private static unsafe IntPtr CheckStaticClassConstructionReturnNonGCStaticBase(S
4242
return nonGcStaticBase;
4343
}
4444

45-
private static unsafe object CheckStaticClassConstructionReturnThreadStaticBase(TypeManagerSlot* pModuleData, int typeTlsIndex, StaticClassConstructionContext* context)
45+
private static unsafe object CheckStaticClassConstructionReturnThreadStaticBase(int typeTlsIndex, TypeManagerSlot* pModuleData, StaticClassConstructionContext* context)
4646
{
47-
object threadStaticBase = ThreadStatics.GetThreadStaticBaseForType(pModuleData, typeTlsIndex);
47+
object threadStaticBase = ThreadStatics.GetThreadStaticBaseForType(typeTlsIndex, pModuleData);
4848
EnsureClassConstructorRun(context);
4949
return threadStaticBase;
5050
}

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X64/X64ReadyToRunGenericHelperNode.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,14 @@ protected sealed override void EmitCode(NodeFactory factory, ref X64Emitter enco
172172
helperEntrypoint = factory.HelperEntrypoint(HelperEntrypoint.GetThreadStaticBaseForType);
173173
}
174174

175-
// First arg: address of the TypeManager slot that provides the helper with
176-
// information about module index and the type manager instance (which is used
177-
// for initialization on first access).
178-
AddrMode loadFromArg1 = new AddrMode(encoder.TargetRegister.Arg1, null, 0, 0, AddrModeSize.Int64);
179-
encoder.EmitMOV(encoder.TargetRegister.Arg0, ref loadFromArg1);
180-
181-
// Second arg: index of the type in the ThreadStatic section of the modules
175+
// Arg0: index of the type in the ThreadStatic section of the modules
182176
AddrMode loadFromArg1AndDelta = new AddrMode(encoder.TargetRegister.Arg1, null, factory.Target.PointerSize, 0, AddrModeSize.Int64);
183-
encoder.EmitMOV(encoder.TargetRegister.Arg1, ref loadFromArg1AndDelta);
177+
encoder.EmitMOV(encoder.TargetRegister.Arg0, ref loadFromArg1AndDelta);
178+
179+
// Arg1: address of the TypeManager slot that provides the helper with
180+
// information about module index and the type manager instance (which is used for initialization on first access).
181+
AddrMode loadFromArg1 = new AddrMode(encoder.TargetRegister.Arg1, null, 0, 0, AddrModeSize.Int64);
182+
encoder.EmitMOV(encoder.TargetRegister.Arg1, ref loadFromArg1);
184183

185184
encoder.EmitJMP(helperEntrypoint);
186185
}

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X64/X64ReadyToRunHelperNode.cs

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -70,39 +70,61 @@ protected override void EmitCode(NodeFactory factory, ref X64Emitter encoder, bo
7070

7171
case ReadyToRunHelperId.GetThreadStaticBase:
7272
{
73-
bool isMultiFile = !factory.CompilationModuleGroup.IsSingleFileCompilation;
74-
7573
MetadataType target = (MetadataType)Target;
74+
encoder.EmitLEAQ(encoder.TargetRegister.Arg1, factory.TypeThreadStaticIndex(target));
7675

77-
encoder.EmitLEAQ(encoder.TargetRegister.Arg2, factory.TypeThreadStaticIndex(target));
78-
79-
// First arg: address of the TypeManager slot that provides the helper with
80-
// information about module index and the type manager instance (which is used
81-
// for initialization on first access).
82-
AddrMode loadFromArg2 = new AddrMode(encoder.TargetRegister.Arg2, null, 0, 0, AddrModeSize.Int64);
83-
encoder.EmitMOV(encoder.TargetRegister.Arg0, ref loadFromArg2);
84-
85-
// Second arg: index of the type in the ThreadStatic section of the modules
86-
AddrMode loadFromArg2AndDelta = new AddrMode(encoder.TargetRegister.Arg2, null, factory.Target.PointerSize, 0, AddrModeSize.Int32);
87-
encoder.EmitMOV(encoder.TargetRegister.Arg1, ref loadFromArg2AndDelta);
88-
89-
ISymbolNode helper = isMultiFile ?
90-
factory.HelperEntrypoint(HelperEntrypoint.GetThreadStaticBaseForType) :
91-
factory.ExternSymbol("RhpGetThreadStaticBaseForType");
76+
// Arg0: index of the type in the ThreadStatic section of the modules
77+
AddrMode loadFromArg1AndDelta = new AddrMode(encoder.TargetRegister.Arg1, null, factory.Target.PointerSize, 0, AddrModeSize.Int32);
78+
encoder.EmitMOV(encoder.TargetRegister.Arg0, ref loadFromArg1AndDelta);
9279

93-
if (!factory.PreinitializationManager.HasLazyStaticConstructor(target))
80+
bool isSingleFile = factory.CompilationModuleGroup.IsSingleFileCompilation;
81+
if (isSingleFile)
9482
{
95-
encoder.EmitJMP(helper);
83+
ISymbolNode helper = factory.ExternSymbol("RhpGetThreadStaticBaseForType");
84+
if (!factory.PreinitializationManager.HasLazyStaticConstructor(target))
85+
{
86+
encoder.EmitJMP(helper);
87+
}
88+
else
89+
{
90+
// check if class is initialized
91+
encoder.EmitLEAQ(encoder.TargetRegister.Arg2, factory.TypeNonGCStaticsSymbol(target), -NonGCStaticsNode.GetClassConstructorContextSize(factory.Target));
92+
AddrMode initialized = new AddrMode(encoder.TargetRegister.Arg2, null, 0, 0, AddrModeSize.Int64);
93+
encoder.EmitCMP(ref initialized, 0);
94+
encoder.EmitJE(helper);
95+
96+
// Arg1: address of the TypeManager slot that provides the helper with
97+
// information about module index and the type manager instance (which is used for initialization on first access).
98+
AddrMode loadFromArg1 = new AddrMode(encoder.TargetRegister.Arg1, null, 0, 0, AddrModeSize.Int64);
99+
encoder.EmitMOV(encoder.TargetRegister.Arg1, ref loadFromArg1);
100+
encoder.EmitJMP(factory.HelperEntrypoint(HelperEntrypoint.EnsureClassConstructorRunAndReturnThreadStaticBase));
101+
}
96102
}
97103
else
98104
{
99-
encoder.EmitLEAQ(encoder.TargetRegister.Arg2, factory.TypeNonGCStaticsSymbol(target), - NonGCStaticsNode.GetClassConstructorContextSize(factory.Target));
100-
101-
AddrMode initialized = new AddrMode(encoder.TargetRegister.Arg2, null, 0, 0, AddrModeSize.Int64);
102-
encoder.EmitCMP(ref initialized, 0);
103-
encoder.EmitJE(helper);
104-
105-
encoder.EmitJMP(factory.HelperEntrypoint(HelperEntrypoint.EnsureClassConstructorRunAndReturnThreadStaticBase));
105+
ISymbolNode helper = factory.HelperEntrypoint(HelperEntrypoint.GetThreadStaticBaseForType);
106+
107+
// Arg1: address of the TypeManager slot that provides the helper with
108+
// information about module index and the type manager instance (which is used for initialization on first access).
109+
AddrMode loadFromArg1 = new AddrMode(encoder.TargetRegister.Arg1, null, 0, 0, AddrModeSize.Int64);
110+
encoder.EmitMOV(encoder.TargetRegister.Arg1, ref loadFromArg1);
111+
112+
if (!factory.PreinitializationManager.HasLazyStaticConstructor(target))
113+
{
114+
encoder.EmitJMP(helper);
115+
}
116+
else
117+
{
118+
// check if class is initialized
119+
encoder.EmitLEAQ(encoder.TargetRegister.Arg2, factory.TypeNonGCStaticsSymbol(target), - NonGCStaticsNode.GetClassConstructorContextSize(factory.Target));
120+
121+
AddrMode initialized = new AddrMode(encoder.TargetRegister.Arg2, null, 0, 0, AddrModeSize.Int64);
122+
encoder.EmitCMP(ref initialized, 0);
123+
encoder.EmitJE(helper);
124+
125+
// call another helper (same arguments)
126+
encoder.EmitJMP(factory.HelperEntrypoint(HelperEntrypoint.EnsureClassConstructorRunAndReturnThreadStaticBase));
127+
}
106128
}
107129
}
108130
break;

0 commit comments

Comments
 (0)