130130import com .oracle .svm .core .graal .code .SubstrateLIRGenerator ;
131131import com .oracle .svm .core .graal .code .SubstrateNodeLIRBuilder ;
132132import com .oracle .svm .core .graal .lir .VerificationMarkerOp ;
133- import com .oracle .svm .core .graal .meta .RuntimeConfiguration ;
133+ import com .oracle .svm .core .graal .meta .KnownOffsets ;
134134import com .oracle .svm .core .graal .meta .SubstrateForeignCallLinkage ;
135135import com .oracle .svm .core .graal .meta .SubstrateRegisterConfig ;
136136import com .oracle .svm .core .graal .nodes .CGlobalDataLoadAddressNode ;
@@ -177,7 +177,6 @@ public SubstrateAArch64Backend(Providers providers) {
177177 public static class SubstrateAArch64DirectCallOp extends AArch64Call .DirectCallOp {
178178 public static final LIRInstructionClass <SubstrateAArch64DirectCallOp > TYPE = LIRInstructionClass .create (SubstrateAArch64DirectCallOp .class );
179179
180- private final RuntimeConfiguration runtimeConfiguration ;
181180 private final int newThreadStatus ;
182181 @ Use ({REG , OperandFlag .ILLEGAL }) private Value javaFrameAnchor ;
183182
@@ -189,10 +188,9 @@ public static class SubstrateAArch64DirectCallOp extends AArch64Call.DirectCallO
189188 */
190189 @ Temp ({REG }) private Value linkReg ;
191190
192- public SubstrateAArch64DirectCallOp (RuntimeConfiguration runtimeConfiguration , ResolvedJavaMethod callTarget , Value result , Value [] parameters , Value [] temps , LIRFrameState state ,
191+ public SubstrateAArch64DirectCallOp (ResolvedJavaMethod callTarget , Value result , Value [] parameters , Value [] temps , LIRFrameState state ,
193192 Value javaFrameAnchor , int newThreadStatus , boolean destroysCallerSavedRegisters , Value exceptionTemp ) {
194193 super (TYPE , callTarget , result , parameters , temps , state );
195- this .runtimeConfiguration = runtimeConfiguration ;
196194 this .javaFrameAnchor = javaFrameAnchor ;
197195 this .newThreadStatus = newThreadStatus ;
198196 this .destroysCallerSavedRegisters = destroysCallerSavedRegisters ;
@@ -202,7 +200,7 @@ public SubstrateAArch64DirectCallOp(RuntimeConfiguration runtimeConfiguration, R
202200
203201 @ Override
204202 public void emitCode (CompilationResultBuilder crb , AArch64MacroAssembler masm ) {
205- maybeTransitionToNative (crb , masm , runtimeConfiguration , javaFrameAnchor , state , newThreadStatus );
203+ maybeTransitionToNative (crb , masm , javaFrameAnchor , state , newThreadStatus );
206204 AArch64Call .directCall (crb , masm , callTarget , null , state );
207205 }
208206
@@ -215,7 +213,6 @@ public boolean destroysCallerSavedRegisters() {
215213 @ Opcode ("CALL_INDIRECT" )
216214 public static class SubstrateAArch64IndirectCallOp extends AArch64Call .IndirectCallOp {
217215 public static final LIRInstructionClass <SubstrateAArch64IndirectCallOp > TYPE = LIRInstructionClass .create (SubstrateAArch64IndirectCallOp .class );
218- private final RuntimeConfiguration runtimeConfiguration ;
219216 private final int newThreadStatus ;
220217 @ Use ({REG , OperandFlag .ILLEGAL }) private Value javaFrameAnchor ;
221218
@@ -227,10 +224,9 @@ public static class SubstrateAArch64IndirectCallOp extends AArch64Call.IndirectC
227224 */
228225 @ Temp ({REG }) private Value linkReg ;
229226
230- public SubstrateAArch64IndirectCallOp (RuntimeConfiguration runtimeConfiguration , ResolvedJavaMethod callTarget , Value result , Value [] parameters , Value [] temps , Value targetAddress ,
227+ public SubstrateAArch64IndirectCallOp (ResolvedJavaMethod callTarget , Value result , Value [] parameters , Value [] temps , Value targetAddress ,
231228 LIRFrameState state , Value javaFrameAnchor , int newThreadStatus , boolean destroysCallerSavedRegisters , Value exceptionTemp ) {
232229 super (TYPE , callTarget , result , parameters , temps , targetAddress , state );
233- this .runtimeConfiguration = runtimeConfiguration ;
234230 this .javaFrameAnchor = javaFrameAnchor ;
235231 this .newThreadStatus = newThreadStatus ;
236232 this .destroysCallerSavedRegisters = destroysCallerSavedRegisters ;
@@ -240,7 +236,7 @@ public SubstrateAArch64IndirectCallOp(RuntimeConfiguration runtimeConfiguration,
240236
241237 @ Override
242238 public void emitCode (CompilationResultBuilder crb , AArch64MacroAssembler masm ) {
243- maybeTransitionToNative (crb , masm , runtimeConfiguration , javaFrameAnchor , state , newThreadStatus );
239+ maybeTransitionToNative (crb , masm , javaFrameAnchor , state , newThreadStatus );
244240 super .emitCode (crb , masm );
245241 }
246242
@@ -250,8 +246,7 @@ public boolean destroysCallerSavedRegisters() {
250246 }
251247 }
252248
253- static void maybeTransitionToNative (CompilationResultBuilder crb , AArch64MacroAssembler masm , RuntimeConfiguration runtimeConfiguration , Value javaFrameAnchor , LIRFrameState state ,
254- int newThreadStatus ) {
249+ static void maybeTransitionToNative (CompilationResultBuilder crb , AArch64MacroAssembler masm , Value javaFrameAnchor , LIRFrameState state , int newThreadStatus ) {
255250 if (ValueUtil .isIllegal (javaFrameAnchor )) {
256251 /* Not a call that needs to set up a JavaFrameAnchor. */
257252 assert newThreadStatus == StatusSupport .STATUS_ILLEGAL ;
@@ -269,17 +264,18 @@ static void maybeTransitionToNative(CompilationResultBuilder crb, AArch64MacroAs
269264 * metadata is registered for the end of the instruction just works.
270265 */
271266 int startPos = masm .position ();
267+ KnownOffsets knownOffsets = KnownOffsets .singleton ();
272268 try (ScratchRegister scratch = masm .getScratchRegister ()) {
273269 Register tempRegister = scratch .getRegister ();
274270 // Save PC
275271 masm .adr (tempRegister , 4 ); // Read PC + 4
276272 crb .recordIndirectCall (startPos , masm .position (), null , state );
277273 masm .str (64 , tempRegister ,
278- AArch64Address .createImmediateAddress (64 , AArch64Address .AddressingMode .IMMEDIATE_UNSIGNED_SCALED , anchor , runtimeConfiguration .getJavaFrameAnchorLastIPOffset ()));
274+ AArch64Address .createImmediateAddress (64 , AArch64Address .AddressingMode .IMMEDIATE_UNSIGNED_SCALED , anchor , knownOffsets .getJavaFrameAnchorLastIPOffset ()));
279275 // Save SP
280276 masm .mov (64 , tempRegister , sp );
281277 masm .str (64 , tempRegister ,
282- AArch64Address .createImmediateAddress (64 , AArch64Address .AddressingMode .IMMEDIATE_UNSIGNED_SCALED , anchor , runtimeConfiguration .getJavaFrameAnchorLastSPOffset ()));
278+ AArch64Address .createImmediateAddress (64 , AArch64Address .AddressingMode .IMMEDIATE_UNSIGNED_SCALED , anchor , knownOffsets .getJavaFrameAnchorLastSPOffset ()));
283279 }
284280
285281 if (SubstrateOptions .MultiThreaded .getValue ()) {
@@ -292,7 +288,7 @@ static void maybeTransitionToNative(CompilationResultBuilder crb, AArch64MacroAs
292288 Register statusValueRegister = scratch1 .getRegister ();
293289 Register statusAddressRegister = scratch2 .getRegister ();
294290 masm .mov (statusValueRegister , newThreadStatus );
295- masm .loadAlignedAddress (32 , statusAddressRegister , ReservedRegisters .singleton ().getThreadRegister (), runtimeConfiguration .getVMThreadStatusOffset ());
291+ masm .loadAlignedAddress (32 , statusAddressRegister , ReservedRegisters .singleton ().getThreadRegister (), knownOffsets .getVMThreadStatusOffset ());
296292 masm .stlr (32 , statusValueRegister , statusAddressRegister );
297293 }
298294 }
@@ -394,7 +390,7 @@ protected Value emitIndirectForeignCallAddress(ForeignCallLinkage linkage) {
394390 Value codeOffsetInImage = emitConstant (wordKind , JavaConstant .forLong (targetMethod .getCodeOffsetInImage ()));
395391 Value codeInfo = emitJavaConstant (SubstrateObjectConstant .forObject (CodeInfoTable .getImageCodeCache ()));
396392 int size = wordKind .getPlatformKind ().getSizeInBytes () * Byte .SIZE ;
397- int codeStartFieldOffset = getRuntimeConfiguration ().getImageCodeInfoCodeStartOffset ();
393+ int codeStartFieldOffset = KnownOffsets . singleton ().getImageCodeInfoCodeStartOffset ();
398394 Value codeStartField = AArch64AddressValue .makeAddress (wordKind , size , asAllocatable (codeInfo ), codeStartFieldOffset );
399395 Value codeStart = getArithmetic ().emitLoad (wordKind , codeStartField , null );
400396 return getArithmetic ().emitAdd (codeStart , codeOffsetInImage , false );
@@ -407,11 +403,11 @@ protected void emitForeignCallOp(ForeignCallLinkage linkage, Value targetAddress
407403 if (shouldEmitOnlyIndirectCalls ()) {
408404 RegisterValue targetRegister = AArch64 .lr .asValue (FrameAccess .getWordStamp ().getLIRKind (getLIRKindTool ()));
409405 emitMove (targetRegister , targetAddress );
410- append (new SubstrateAArch64IndirectCallOp (getRuntimeConfiguration (), targetMethod , result , arguments , temps , targetRegister , info , Value .ILLEGAL , StatusSupport .STATUS_ILLEGAL ,
406+ append (new SubstrateAArch64IndirectCallOp (targetMethod , result , arguments , temps , targetRegister , info , Value .ILLEGAL , StatusSupport .STATUS_ILLEGAL ,
411407 getDestroysCallerSavedRegisters (targetMethod ), Value .ILLEGAL ));
412408 } else {
413409 assert targetAddress == null ;
414- append (new SubstrateAArch64DirectCallOp (getRuntimeConfiguration (), targetMethod , result , arguments , temps , info , Value .ILLEGAL , StatusSupport .STATUS_ILLEGAL ,
410+ append (new SubstrateAArch64DirectCallOp (targetMethod , result , arguments , temps , info , Value .ILLEGAL , StatusSupport .STATUS_ILLEGAL ,
415411 getDestroysCallerSavedRegisters (targetMethod ), Value .ILLEGAL ));
416412 }
417413 }
@@ -579,7 +575,7 @@ private Value getExceptionTemp(CallTargetNode callTarget) {
579575 @ Override
580576 protected void emitDirectCall (DirectCallTargetNode callTarget , Value result , Value [] parameters , Value [] temps , LIRFrameState callState ) {
581577 ResolvedJavaMethod targetMethod = callTarget .targetMethod ();
582- append (new SubstrateAArch64DirectCallOp (getRuntimeConfiguration (), targetMethod , result , parameters , temps , callState , setupJavaFrameAnchor (callTarget ),
578+ append (new SubstrateAArch64DirectCallOp (targetMethod , result , parameters , temps , callState , setupJavaFrameAnchor (callTarget ),
583579 getNewThreadStatus (callTarget ), getDestroysCallerSavedRegisters (targetMethod ), getExceptionTemp (callTarget )));
584580 }
585581
@@ -590,7 +586,7 @@ protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result,
590586 AllocatableValue targetAddress = targetRegister .asValue (FrameAccess .getWordStamp ().getLIRKind (getLIRGeneratorTool ().getLIRKindTool ()));
591587 gen .emitMove (targetAddress , operand (callTarget .computedAddress ()));
592588 ResolvedJavaMethod targetMethod = callTarget .targetMethod ();
593- append (new SubstrateAArch64IndirectCallOp (getRuntimeConfiguration (), targetMethod , result , parameters , temps , targetAddress , callState , setupJavaFrameAnchor (callTarget ),
589+ append (new SubstrateAArch64IndirectCallOp (targetMethod , result , parameters , temps , targetAddress , callState , setupJavaFrameAnchor (callTarget ),
594590 getNewThreadStatus (callTarget ), getDestroysCallerSavedRegisters (targetMethod ), getExceptionTemp (callTarget )));
595591 }
596592
0 commit comments