Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.graalvm.compiler.nodes.AbstractBeginNode;
import org.graalvm.compiler.nodes.AbstractMergeNode;
import org.graalvm.compiler.nodes.BeginNode;
import org.graalvm.compiler.nodes.CallTargetNode;
import org.graalvm.compiler.nodes.CallTargetNode.InvokeKind;
import org.graalvm.compiler.nodes.EndNode;
import org.graalvm.compiler.nodes.FixedNode;
Expand Down Expand Up @@ -564,7 +565,7 @@ public InvokeWithExceptionNode startInvokeWithException(ResolvedJavaMethod metho
return startInvokeWithException(callTarget, frameStateBuilder, invokeBci);
}

public InvokeWithExceptionNode startInvokeWithException(MethodCallTargetNode callTarget, FrameStateBuilder frameStateBuilder, int invokeBci) {
public InvokeWithExceptionNode startInvokeWithException(CallTargetNode callTarget, FrameStateBuilder frameStateBuilder, int invokeBci) {
ExceptionObjectNode exceptionObject = createExceptionObjectNode(frameStateBuilder, invokeBci);
InvokeWithExceptionNode invoke = append(new InvokeWithExceptionNode(callTarget, exceptionObject, invokeBci));
AbstractBeginNode noExceptionEdge = graph.add(new BeginNode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
import com.oracle.svm.core.graal.code.SubstrateLIRGenerator;
import com.oracle.svm.core.graal.code.SubstrateNodeLIRBuilder;
import com.oracle.svm.core.graal.lir.VerificationMarkerOp;
import com.oracle.svm.core.graal.meta.RuntimeConfiguration;
import com.oracle.svm.core.graal.meta.KnownOffsets;
import com.oracle.svm.core.graal.meta.SubstrateForeignCallLinkage;
import com.oracle.svm.core.graal.meta.SubstrateRegisterConfig;
import com.oracle.svm.core.graal.nodes.CGlobalDataLoadAddressNode;
Expand Down Expand Up @@ -177,7 +177,6 @@ public SubstrateAArch64Backend(Providers providers) {
public static class SubstrateAArch64DirectCallOp extends AArch64Call.DirectCallOp {
public static final LIRInstructionClass<SubstrateAArch64DirectCallOp> TYPE = LIRInstructionClass.create(SubstrateAArch64DirectCallOp.class);

private final RuntimeConfiguration runtimeConfiguration;
private final int newThreadStatus;
@Use({REG, OperandFlag.ILLEGAL}) private Value javaFrameAnchor;

Expand All @@ -189,10 +188,9 @@ public static class SubstrateAArch64DirectCallOp extends AArch64Call.DirectCallO
*/
@Temp({REG}) private Value linkReg;

public SubstrateAArch64DirectCallOp(RuntimeConfiguration runtimeConfiguration, ResolvedJavaMethod callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState state,
public SubstrateAArch64DirectCallOp(ResolvedJavaMethod callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState state,
Value javaFrameAnchor, int newThreadStatus, boolean destroysCallerSavedRegisters, Value exceptionTemp) {
super(TYPE, callTarget, result, parameters, temps, state);
this.runtimeConfiguration = runtimeConfiguration;
this.javaFrameAnchor = javaFrameAnchor;
this.newThreadStatus = newThreadStatus;
this.destroysCallerSavedRegisters = destroysCallerSavedRegisters;
Expand All @@ -202,7 +200,7 @@ public SubstrateAArch64DirectCallOp(RuntimeConfiguration runtimeConfiguration, R

@Override
public void emitCode(CompilationResultBuilder crb, AArch64MacroAssembler masm) {
maybeTransitionToNative(crb, masm, runtimeConfiguration, javaFrameAnchor, state, newThreadStatus);
maybeTransitionToNative(crb, masm, javaFrameAnchor, state, newThreadStatus);
AArch64Call.directCall(crb, masm, callTarget, null, state);
}

Expand All @@ -215,7 +213,6 @@ public boolean destroysCallerSavedRegisters() {
@Opcode("CALL_INDIRECT")
public static class SubstrateAArch64IndirectCallOp extends AArch64Call.IndirectCallOp {
public static final LIRInstructionClass<SubstrateAArch64IndirectCallOp> TYPE = LIRInstructionClass.create(SubstrateAArch64IndirectCallOp.class);
private final RuntimeConfiguration runtimeConfiguration;
private final int newThreadStatus;
@Use({REG, OperandFlag.ILLEGAL}) private Value javaFrameAnchor;

Expand All @@ -227,10 +224,9 @@ public static class SubstrateAArch64IndirectCallOp extends AArch64Call.IndirectC
*/
@Temp({REG}) private Value linkReg;

public SubstrateAArch64IndirectCallOp(RuntimeConfiguration runtimeConfiguration, ResolvedJavaMethod callTarget, Value result, Value[] parameters, Value[] temps, Value targetAddress,
public SubstrateAArch64IndirectCallOp(ResolvedJavaMethod callTarget, Value result, Value[] parameters, Value[] temps, Value targetAddress,
LIRFrameState state, Value javaFrameAnchor, int newThreadStatus, boolean destroysCallerSavedRegisters, Value exceptionTemp) {
super(TYPE, callTarget, result, parameters, temps, targetAddress, state);
this.runtimeConfiguration = runtimeConfiguration;
this.javaFrameAnchor = javaFrameAnchor;
this.newThreadStatus = newThreadStatus;
this.destroysCallerSavedRegisters = destroysCallerSavedRegisters;
Expand All @@ -240,7 +236,7 @@ public SubstrateAArch64IndirectCallOp(RuntimeConfiguration runtimeConfiguration,

@Override
public void emitCode(CompilationResultBuilder crb, AArch64MacroAssembler masm) {
maybeTransitionToNative(crb, masm, runtimeConfiguration, javaFrameAnchor, state, newThreadStatus);
maybeTransitionToNative(crb, masm, javaFrameAnchor, state, newThreadStatus);
super.emitCode(crb, masm);
}

Expand All @@ -250,8 +246,7 @@ public boolean destroysCallerSavedRegisters() {
}
}

static void maybeTransitionToNative(CompilationResultBuilder crb, AArch64MacroAssembler masm, RuntimeConfiguration runtimeConfiguration, Value javaFrameAnchor, LIRFrameState state,
int newThreadStatus) {
static void maybeTransitionToNative(CompilationResultBuilder crb, AArch64MacroAssembler masm, Value javaFrameAnchor, LIRFrameState state, int newThreadStatus) {
if (ValueUtil.isIllegal(javaFrameAnchor)) {
/* Not a call that needs to set up a JavaFrameAnchor. */
assert newThreadStatus == StatusSupport.STATUS_ILLEGAL;
Expand All @@ -269,17 +264,18 @@ static void maybeTransitionToNative(CompilationResultBuilder crb, AArch64MacroAs
* metadata is registered for the end of the instruction just works.
*/
int startPos = masm.position();
KnownOffsets knownOffsets = KnownOffsets.singleton();
try (ScratchRegister scratch = masm.getScratchRegister()) {
Register tempRegister = scratch.getRegister();
// Save PC
masm.adr(tempRegister, 4); // Read PC + 4
crb.recordIndirectCall(startPos, masm.position(), null, state);
masm.str(64, tempRegister,
AArch64Address.createImmediateAddress(64, AArch64Address.AddressingMode.IMMEDIATE_UNSIGNED_SCALED, anchor, runtimeConfiguration.getJavaFrameAnchorLastIPOffset()));
AArch64Address.createImmediateAddress(64, AArch64Address.AddressingMode.IMMEDIATE_UNSIGNED_SCALED, anchor, knownOffsets.getJavaFrameAnchorLastIPOffset()));
// Save SP
masm.mov(64, tempRegister, sp);
masm.str(64, tempRegister,
AArch64Address.createImmediateAddress(64, AArch64Address.AddressingMode.IMMEDIATE_UNSIGNED_SCALED, anchor, runtimeConfiguration.getJavaFrameAnchorLastSPOffset()));
AArch64Address.createImmediateAddress(64, AArch64Address.AddressingMode.IMMEDIATE_UNSIGNED_SCALED, anchor, knownOffsets.getJavaFrameAnchorLastSPOffset()));
}

if (SubstrateOptions.MultiThreaded.getValue()) {
Expand All @@ -292,7 +288,7 @@ static void maybeTransitionToNative(CompilationResultBuilder crb, AArch64MacroAs
Register statusValueRegister = scratch1.getRegister();
Register statusAddressRegister = scratch2.getRegister();
masm.mov(statusValueRegister, newThreadStatus);
masm.loadAlignedAddress(32, statusAddressRegister, ReservedRegisters.singleton().getThreadRegister(), runtimeConfiguration.getVMThreadStatusOffset());
masm.loadAlignedAddress(32, statusAddressRegister, ReservedRegisters.singleton().getThreadRegister(), knownOffsets.getVMThreadStatusOffset());
masm.stlr(32, statusValueRegister, statusAddressRegister);
}
}
Expand Down Expand Up @@ -394,7 +390,7 @@ protected Value emitIndirectForeignCallAddress(ForeignCallLinkage linkage) {
Value codeOffsetInImage = emitConstant(wordKind, JavaConstant.forLong(targetMethod.getCodeOffsetInImage()));
Value codeInfo = emitJavaConstant(SubstrateObjectConstant.forObject(CodeInfoTable.getImageCodeCache()));
int size = wordKind.getPlatformKind().getSizeInBytes() * Byte.SIZE;
int codeStartFieldOffset = getRuntimeConfiguration().getImageCodeInfoCodeStartOffset();
int codeStartFieldOffset = KnownOffsets.singleton().getImageCodeInfoCodeStartOffset();
Value codeStartField = AArch64AddressValue.makeAddress(wordKind, size, asAllocatable(codeInfo), codeStartFieldOffset);
Value codeStart = getArithmetic().emitLoad(wordKind, codeStartField, null);
return getArithmetic().emitAdd(codeStart, codeOffsetInImage, false);
Expand All @@ -407,11 +403,11 @@ protected void emitForeignCallOp(ForeignCallLinkage linkage, Value targetAddress
if (shouldEmitOnlyIndirectCalls()) {
RegisterValue targetRegister = AArch64.lr.asValue(FrameAccess.getWordStamp().getLIRKind(getLIRKindTool()));
emitMove(targetRegister, targetAddress);
append(new SubstrateAArch64IndirectCallOp(getRuntimeConfiguration(), targetMethod, result, arguments, temps, targetRegister, info, Value.ILLEGAL, StatusSupport.STATUS_ILLEGAL,
append(new SubstrateAArch64IndirectCallOp(targetMethod, result, arguments, temps, targetRegister, info, Value.ILLEGAL, StatusSupport.STATUS_ILLEGAL,
getDestroysCallerSavedRegisters(targetMethod), Value.ILLEGAL));
} else {
assert targetAddress == null;
append(new SubstrateAArch64DirectCallOp(getRuntimeConfiguration(), targetMethod, result, arguments, temps, info, Value.ILLEGAL, StatusSupport.STATUS_ILLEGAL,
append(new SubstrateAArch64DirectCallOp(targetMethod, result, arguments, temps, info, Value.ILLEGAL, StatusSupport.STATUS_ILLEGAL,
getDestroysCallerSavedRegisters(targetMethod), Value.ILLEGAL));
}
}
Expand Down Expand Up @@ -579,7 +575,7 @@ private Value getExceptionTemp(CallTargetNode callTarget) {
@Override
protected void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) {
ResolvedJavaMethod targetMethod = callTarget.targetMethod();
append(new SubstrateAArch64DirectCallOp(getRuntimeConfiguration(), targetMethod, result, parameters, temps, callState, setupJavaFrameAnchor(callTarget),
append(new SubstrateAArch64DirectCallOp(targetMethod, result, parameters, temps, callState, setupJavaFrameAnchor(callTarget),
getNewThreadStatus(callTarget), getDestroysCallerSavedRegisters(targetMethod), getExceptionTemp(callTarget)));
}

Expand All @@ -590,7 +586,7 @@ protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result,
AllocatableValue targetAddress = targetRegister.asValue(FrameAccess.getWordStamp().getLIRKind(getLIRGeneratorTool().getLIRKindTool()));
gen.emitMove(targetAddress, operand(callTarget.computedAddress()));
ResolvedJavaMethod targetMethod = callTarget.targetMethod();
append(new SubstrateAArch64IndirectCallOp(getRuntimeConfiguration(), targetMethod, result, parameters, temps, targetAddress, callState, setupJavaFrameAnchor(callTarget),
append(new SubstrateAArch64IndirectCallOp(targetMethod, result, parameters, temps, targetAddress, callState, setupJavaFrameAnchor(callTarget),
getNewThreadStatus(callTarget), getDestroysCallerSavedRegisters(targetMethod), getExceptionTemp(callTarget)));
}

Expand Down
Loading