use of org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage in project graal by oracle.
the class AMD64HotSpotLIRGenerator method emitForeignCallOp.
@Override
protected void emitForeignCallOp(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
currentRuntimeCallInfo = info;
HotSpotForeignCallLinkage hsLinkage = (HotSpotForeignCallLinkage) linkage;
AMD64 arch = (AMD64) target().arch;
if (arch.getFeatures().contains(AMD64.CPUFeature.AVX) && hsLinkage.mayContainFP() && !hsLinkage.isCompiledStub()) {
/*
* If the target may contain FP ops, and it is not compiled by us, we may have an
* AVX-SSE transition.
*
* We exclude the argument registers from the zeroing LIR instruction since it violates
* the LIR semantics of @Temp that values must not be live. Note that the emitted
* machine instruction actually zeros _all_ XMM registers which is fine since we know
* that their upper half is not used.
*/
append(new AMD64VZeroUpper(arguments));
}
super.emitForeignCallOp(linkage, result, arguments, temps, info);
}
use of org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage in project graal by oracle.
the class AMD64HotSpotLIRGenerator method emitForeignCall.
@Override
public Variable emitForeignCall(ForeignCallLinkage linkage, LIRFrameState state, Value... args) {
HotSpotForeignCallLinkage hotspotLinkage = (HotSpotForeignCallLinkage) linkage;
boolean destroysRegisters = hotspotLinkage.destroysRegisters();
AMD64SaveRegistersOp save = null;
Stub stub = getStub();
if (destroysRegisters) {
if (stub != null && stub.preservesRegisters()) {
Register[] savedRegisters = getRegisterConfig().getAllocatableRegisters().toArray();
save = emitSaveAllRegisters(savedRegisters, true);
}
}
Variable result;
LIRFrameState debugInfo = null;
if (hotspotLinkage.needsDebugInfo()) {
debugInfo = state;
assert debugInfo != null || stub != null;
}
if (hotspotLinkage.needsJavaFrameAnchor()) {
Register thread = getProviders().getRegisters().getThreadRegister();
append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread));
result = super.emitForeignCall(hotspotLinkage, debugInfo, args);
append(new AMD64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaFpOffset(), config.threadLastJavaPcOffset(), thread));
} else {
result = super.emitForeignCall(hotspotLinkage, debugInfo, args);
}
if (destroysRegisters) {
if (stub != null) {
if (stub.preservesRegisters()) {
HotSpotLIRGenerationResult generationResult = getResult();
LIRFrameState key = currentRuntimeCallInfo;
if (key == null) {
key = LIRFrameState.NO_STATE;
}
assert !generationResult.getCalleeSaveInfo().containsKey(key);
generationResult.getCalleeSaveInfo().put(key, save);
emitRestoreRegisters(save);
}
}
}
return result;
}
use of org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage in project graal by oracle.
the class AArch64HotSpotLIRGenerator method emitForeignCall.
@Override
public Variable emitForeignCall(ForeignCallLinkage linkage, LIRFrameState state, Value... args) {
HotSpotForeignCallLinkage hotspotLinkage = (HotSpotForeignCallLinkage) linkage;
Variable result;
LIRFrameState debugInfo = null;
if (hotspotLinkage.needsDebugInfo()) {
debugInfo = state;
assert debugInfo != null || getStub() != null;
}
if (linkage.destroysRegisters() || hotspotLinkage.needsJavaFrameAnchor()) {
HotSpotRegistersProvider registers = getProviders().getRegisters();
Register thread = registers.getThreadRegister();
Variable scratch = newVariable(LIRKind.value(target().arch.getWordKind()));
// We need a label for the return address.
label = new Label();
append(new AArch64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadLastJavaFpOffset(), thread, scratch, label));
result = super.emitForeignCall(hotspotLinkage, debugInfo, args);
append(new AArch64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaFpOffset(), thread));
// Clear it out so it's not being reused later.
label = null;
} else {
result = super.emitForeignCall(hotspotLinkage, debugInfo, args);
}
return result;
}
use of org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage in project graal by oracle.
the class HotSpotForeignCallsProviderImpl method linkForeignCall.
/**
* Creates a {@linkplain ForeignCallStub stub} for a foreign call.
*
* @param descriptor the signature of the call to the stub
* @param address the address of the foreign code to call
* @param prependThread true if the JavaThread value for the current thread is to be prepended
* to the arguments for the call to {@code address}
* @param transition specifies if this is a {@linkplain Transition#LEAF leaf} call
* @param reexecutable specifies if the foreign call can be re-executed without (meaningful)
* side effects. Deoptimization will not return to a point before a foreign call that
* cannot be re-executed.
* @param killedLocations the memory locations killed by the foreign call
*/
public void linkForeignCall(OptionValues options, HotSpotProviders providers, ForeignCallDescriptor descriptor, long address, boolean prependThread, Transition transition, boolean reexecutable, LocationIdentity... killedLocations) {
ForeignCallStub stub = new ForeignCallStub(options, jvmciRuntime, providers, address, descriptor, prependThread, transition, reexecutable, killedLocations);
HotSpotForeignCallLinkage linkage = stub.getLinkage();
HotSpotForeignCallLinkage targetLinkage = stub.getTargetLinkage();
linkage.setCompiledStub(stub);
register(linkage);
register(targetLinkage);
}
Aggregations