Skip to content

Commit 723e2ec

Browse files
committed
arm64
1 parent a752396 commit 723e2ec

File tree

5 files changed

+64
-32
lines changed

5 files changed

+64
-32
lines changed

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMReadyToRunGenericHelperNode.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ protected sealed override void EmitCode(NodeFactory factory, ref ARMEmitter enco
151151
helperEntrypoint = factory.HelperEntrypoint(HelperEntrypoint.GetThreadStaticBaseForType);
152152
}
153153

154-
// First arg: address of the TypeManager slot that provides the helper with
154+
// Arg0: index of the type in the ThreadStatic section of the modules
155+
encoder.EmitLDR(encoder.TargetRegister.Arg0, encoder.TargetRegister.Arg1, factory.Target.PointerSize);
156+
157+
// Arg1: address of the TypeManager slot that provides the helper with
155158
// information about module index and the type manager instance (which is used
156159
// for initialization on first access).
157-
encoder.EmitLDR(encoder.TargetRegister.Arg0, encoder.TargetRegister.Arg1);
158-
159-
// Second arg: index of the type in the ThreadStatic section of the modules
160-
encoder.EmitLDR(encoder.TargetRegister.Arg1, encoder.TargetRegister.Arg1, factory.Target.PointerSize);
160+
encoder.EmitLDR(encoder.TargetRegister.Arg1, encoder.TargetRegister.Arg1);
161161

162162
encoder.EmitJMP(helperEntrypoint);
163163
}

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64ReadyToRunGenericHelperNode.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,13 @@ protected sealed override void EmitCode(NodeFactory factory, ref ARM64Emitter en
163163
helperEntrypoint = factory.HelperEntrypoint(HelperEntrypoint.GetThreadStaticBaseForType);
164164
}
165165

166-
// First arg: address of the TypeManager slot that provides the helper with
166+
// Arg0: index of the type in the ThreadStatic section of the modules
167+
encoder.EmitLDR(encoder.TargetRegister.Arg0, encoder.TargetRegister.Arg1, factory.Target.PointerSize);
168+
169+
// Arg1: address of the TypeManager slot that provides the helper with
167170
// information about module index and the type manager instance (which is used
168171
// for initialization on first access).
169-
encoder.EmitLDR(encoder.TargetRegister.Arg0, encoder.TargetRegister.Arg1);
170-
171-
// Second arg: index of the type in the ThreadStatic section of the modules
172-
encoder.EmitLDR(encoder.TargetRegister.Arg1, encoder.TargetRegister.Arg1, factory.Target.PointerSize);
172+
encoder.EmitLDR(encoder.TargetRegister.Arg1, encoder.TargetRegister.Arg1);
173173

174174
encoder.EmitJMP(helperEntrypoint);
175175
}

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64ReadyToRunHelperNode.cs

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,61 @@ protected override void EmitCode(NodeFactory factory, ref ARM64Emitter encoder,
7171
case ReadyToRunHelperId.GetThreadStaticBase:
7272
{
7373
MetadataType target = (MetadataType)Target;
74-
encoder.EmitMOV(encoder.TargetRegister.Arg2, factory.TypeThreadStaticIndex(target));
74+
encoder.EmitMOV(encoder.TargetRegister.Arg1, factory.TypeThreadStaticIndex(target));
7575

76-
// First arg: address of the TypeManager slot that provides the helper with
77-
// information about module index and the type manager instance (which is used
78-
// for initialization on first access).
79-
encoder.EmitLDR(encoder.TargetRegister.Arg0, encoder.TargetRegister.Arg2);
76+
// Arg0: index of the type in the ThreadStatic section of the modules
77+
encoder.EmitLDR(encoder.TargetRegister.Arg0, encoder.TargetRegister.Arg1, factory.Target.PointerSize);
8078

81-
// Second arg: index of the type in the ThreadStatic section of the modules
82-
encoder.EmitLDR(encoder.TargetRegister.Arg1, encoder.TargetRegister.Arg2, factory.Target.PointerSize);
79+
bool isSingleFile = factory.CompilationModuleGroup.IsSingleFileCompilation;
8380

84-
if (!factory.PreinitializationManager.HasLazyStaticConstructor(target))
81+
if (isSingleFile)
8582
{
86-
encoder.EmitJMP(factory.HelperEntrypoint(HelperEntrypoint.GetThreadStaticBaseForType));
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.EmitMOV(encoder.TargetRegister.Arg2, factory.TypeNonGCStaticsSymbol(target));
92+
encoder.EmitSUB(encoder.TargetRegister.Arg2, NonGCStaticsNode.GetClassConstructorContextSize(factory.Target));
93+
94+
encoder.EmitLDR(encoder.TargetRegister.Arg3, encoder.TargetRegister.Arg2);
95+
encoder.EmitCMP(encoder.TargetRegister.Arg3, 0);
96+
encoder.EmitJE(helper);
97+
98+
// Arg1: address of the TypeManager slot that provides the helper with
99+
// information about module index and the type manager instance (which is used for initialization on first access).
100+
encoder.EmitLDR(encoder.TargetRegister.Arg1, encoder.TargetRegister.Arg1);
101+
encoder.EmitJMP(factory.HelperEntrypoint(HelperEntrypoint.EnsureClassConstructorRunAndReturnThreadStaticBase));
102+
}
87103
}
88104
else
89105
{
90-
encoder.EmitMOV(encoder.TargetRegister.Arg2, factory.TypeNonGCStaticsSymbol(target));
91-
encoder.EmitSUB(encoder.TargetRegister.Arg2, NonGCStaticsNode.GetClassConstructorContextSize(factory.Target));
92-
93-
encoder.EmitLDR(encoder.TargetRegister.Arg3, encoder.TargetRegister.Arg2);
94-
encoder.EmitCMP(encoder.TargetRegister.Arg3, 0);
95-
encoder.EmitJE(factory.HelperEntrypoint(HelperEntrypoint.GetThreadStaticBaseForType));
96-
97-
encoder.EmitJMP(factory.HelperEntrypoint(HelperEntrypoint.EnsureClassConstructorRunAndReturnThreadStaticBase));
106+
ISymbolNode helper = factory.HelperEntrypoint(HelperEntrypoint.GetThreadStaticBaseForType);
107+
108+
// Arg1: address of the TypeManager slot that provides the helper with
109+
// information about module index and the type manager instance (which is used for initialization on first access).
110+
encoder.EmitLDR(encoder.TargetRegister.Arg1, encoder.TargetRegister.Arg1);
111+
112+
if (!factory.PreinitializationManager.HasLazyStaticConstructor(target))
113+
{
114+
encoder.EmitJMP(helper);
115+
}
116+
else
117+
{
118+
// check if class is initialized
119+
encoder.EmitMOV(encoder.TargetRegister.Arg2, factory.TypeNonGCStaticsSymbol(target));
120+
encoder.EmitSUB(encoder.TargetRegister.Arg2, NonGCStaticsNode.GetClassConstructorContextSize(factory.Target));
121+
122+
encoder.EmitLDR(encoder.TargetRegister.Arg3, encoder.TargetRegister.Arg2);
123+
encoder.EmitCMP(encoder.TargetRegister.Arg3, 0);
124+
encoder.EmitJE(helper);
125+
126+
// call another helper (same arguments)
127+
encoder.EmitJMP(factory.HelperEntrypoint(HelperEntrypoint.EnsureClassConstructorRunAndReturnThreadStaticBase));
128+
}
98129
}
99130
}
100131
break;

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_LoongArch64/LoongArch64ReadyToRunGenericHelperNode.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ protected sealed override void EmitCode(NodeFactory factory, ref LoongArch64Emit
152152
helperEntrypoint = factory.HelperEntrypoint(HelperEntrypoint.GetThreadStaticBaseForType);
153153
}
154154

155-
// First arg: address of the TypeManager slot that provides the helper with
155+
// Arg0: index of the type in the ThreadStatic section of the modules
156+
encoder.EmitLD(encoder.TargetRegister.Arg0, encoder.TargetRegister.Arg1, factory.Target.PointerSize);
157+
158+
// Arg1: address of the TypeManager slot that provides the helper with
156159
// information about module index and the type manager instance (which is used
157160
// for initialization on first access).
158-
encoder.EmitLD(encoder.TargetRegister.Arg0, encoder.TargetRegister.Arg1, 0);
159-
160-
// Second arg: index of the type in the ThreadStatic section of the modules
161-
encoder.EmitLD(encoder.TargetRegister.Arg1, encoder.TargetRegister.Arg1, factory.Target.PointerSize);
161+
encoder.EmitLD(encoder.TargetRegister.Arg1, encoder.TargetRegister.Arg1, 0);
162162

163163
encoder.EmitJMP(helperEntrypoint);
164164
}

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_LoongArch64/LoongArch64ReadyToRunHelperNode.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ protected override void EmitCode(NodeFactory factory, ref LoongArch64Emitter enc
7070

7171
case ReadyToRunHelperId.GetThreadStaticBase:
7272
{
73+
// TODO: VS will have to fix this too for the final shape of the helpers
7374
MetadataType target = (MetadataType)Target;
7475
encoder.EmitMOV(encoder.TargetRegister.Arg2, factory.TypeThreadStaticIndex(target));
7576

0 commit comments

Comments
 (0)