use of jdk.vm.ci.code.StackSlot in project graal by oracle.
the class AArch64HotSpotNodeLIRBuilder method emitPrologue.
@Override
protected void emitPrologue(StructuredGraph graph) {
CallingConvention incomingArguments = gen.getResult().getCallingConvention();
Value[] params = new Value[incomingArguments.getArgumentCount() + 2];
for (int i = 0; i < incomingArguments.getArgumentCount(); i++) {
params[i] = incomingArguments.getArgument(i);
if (isStackSlot(params[i])) {
StackSlot slot = ValueUtil.asStackSlot(params[i]);
if (slot.isInCallerFrame() && !gen.getResult().getLIR().hasArgInCallerFrame()) {
gen.getResult().getLIR().setHasArgInCallerFrame();
}
}
}
params[params.length - 2] = fp.asValue(LIRKind.value(AArch64Kind.QWORD));
params[params.length - 1] = lr.asValue(LIRKind.value(AArch64Kind.QWORD));
gen.emitIncomingValues(params);
for (ParameterNode param : graph.getNodes(ParameterNode.TYPE)) {
Value paramValue = params[param.index()];
assert paramValue.getValueKind().equals(getLIRGeneratorTool().getLIRKind(param.stamp(NodeView.DEFAULT))) : paramValue.getValueKind() + " != " + param.stamp(NodeView.DEFAULT);
setResult(param, gen.emitMove(paramValue));
}
}
use of jdk.vm.ci.code.StackSlot in project graal by oracle.
the class AMD64HotSpotNodeLIRBuilder method emitPrologue.
@Override
protected void emitPrologue(StructuredGraph graph) {
CallingConvention incomingArguments = gen.getResult().getCallingConvention();
Value[] params = new Value[incomingArguments.getArgumentCount() + 1];
for (int i = 0; i < params.length - 1; i++) {
params[i] = incomingArguments.getArgument(i);
if (isStackSlot(params[i])) {
StackSlot slot = ValueUtil.asStackSlot(params[i]);
if (slot.isInCallerFrame() && !gen.getResult().getLIR().hasArgInCallerFrame()) {
gen.getResult().getLIR().setHasArgInCallerFrame();
}
}
}
params[params.length - 1] = rbp.asValue(LIRKind.value(AMD64Kind.QWORD));
gen.emitIncomingValues(params);
getGen().emitSaveRbp();
getGen().append(((HotSpotDebugInfoBuilder) getDebugInfoBuilder()).lockStack());
for (ParameterNode param : graph.getNodes(ParameterNode.TYPE)) {
Value paramValue = params[param.index()];
assert paramValue.getValueKind().equals(getLIRGeneratorTool().getLIRKind(param.stamp(NodeView.DEFAULT))) : paramValue.getValueKind() + " != " + param.stamp(NodeView.DEFAULT);
setResult(param, gen.emitMove(paramValue));
}
}
use of jdk.vm.ci.code.StackSlot in project graal by oracle.
the class HotSpotCompiledCodeBuilder method createCompiledCode.
public static HotSpotCompiledCode createCompiledCode(CodeCacheProvider codeCache, ResolvedJavaMethod method, HotSpotCompilationRequest compRequest, CompilationResult compResult) {
String name = compResult.getName();
byte[] targetCode = compResult.getTargetCode();
int targetCodeSize = compResult.getTargetCodeSize();
Site[] sites = getSortedSites(codeCache, compResult);
Assumption[] assumptions = compResult.getAssumptions();
ResolvedJavaMethod[] methods = compResult.getMethods();
List<CodeAnnotation> annotations = compResult.getAnnotations();
Comment[] comments = new Comment[annotations.size()];
if (!annotations.isEmpty()) {
for (int i = 0; i < comments.length; i++) {
CodeAnnotation annotation = annotations.get(i);
String text;
if (annotation instanceof CodeComment) {
CodeComment codeComment = (CodeComment) annotation;
text = codeComment.value;
} else if (annotation instanceof JumpTable) {
JumpTable jumpTable = (JumpTable) annotation;
text = "JumpTable [" + jumpTable.low + " .. " + jumpTable.high + "]";
} else {
text = annotation.toString();
}
comments[i] = new Comment(annotation.position, text);
}
}
DataSection data = compResult.getDataSection();
byte[] dataSection = new byte[data.getSectionSize()];
ByteBuffer buffer = ByteBuffer.wrap(dataSection).order(ByteOrder.nativeOrder());
Builder<DataPatch> patchBuilder = Stream.builder();
data.buildDataSection(buffer, (position, vmConstant) -> {
patchBuilder.accept(new DataPatch(position, new ConstantReference(vmConstant)));
});
int dataSectionAlignment = data.getSectionAlignment();
DataPatch[] dataSectionPatches = patchBuilder.build().toArray(len -> new DataPatch[len]);
int totalFrameSize = compResult.getTotalFrameSize();
StackSlot customStackArea = compResult.getCustomStackArea();
boolean isImmutablePIC = compResult.isImmutablePIC();
if (method instanceof HotSpotResolvedJavaMethod) {
HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) method;
int entryBCI = compResult.getEntryBCI();
boolean hasUnsafeAccess = compResult.hasUnsafeAccess();
int id;
long jvmciEnv;
if (compRequest != null) {
id = compRequest.getId();
jvmciEnv = compRequest.getJvmciEnv();
} else {
id = hsMethod.allocateCompileId(entryBCI);
jvmciEnv = 0L;
}
return new HotSpotCompiledNmethod(name, targetCode, targetCodeSize, sites, assumptions, methods, comments, dataSection, dataSectionAlignment, dataSectionPatches, isImmutablePIC, totalFrameSize, customStackArea, hsMethod, entryBCI, id, jvmciEnv, hasUnsafeAccess);
} else {
return new HotSpotCompiledCode(name, targetCode, targetCodeSize, sites, assumptions, methods, comments, dataSection, dataSectionAlignment, dataSectionPatches, isImmutablePIC, totalFrameSize, customStackArea);
}
}
use of jdk.vm.ci.code.StackSlot in project graal by oracle.
the class HotSpotReferenceMapBuilder method toLocation.
private Location toLocation(Value v, int offset) {
if (isRegister(v)) {
return Location.subregister(asRegister(v), offset);
} else {
StackSlot s = asStackSlot(v);
int totalOffset = s.getOffset(totalFrameSize) + offset;
if (totalOffset > maxOopMapStackOffset) {
throw new PermanentBailoutException("stack offset %d for oopmap is greater than encoding limit %d", totalOffset, maxOopMapStackOffset);
}
return Location.stack(totalOffset);
}
}
use of jdk.vm.ci.code.StackSlot in project graal by oracle.
the class SPARCSaveRegistersOp method emitCode.
@Override
public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
// Can be used with VIS3
// new Movxtod(SPARC.i0, RETURN_REGISTER_STORAGE).emit(masm);
// We abuse the first stackslot for transferring i0 to return_register_storage
// assert slots.length >= 1;
SPARCAddress slot0Address = (SPARCAddress) crb.asAddress(slots[0]);
masm.stx(SPARC.i0, slot0Address);
masm.lddf(slot0Address, RETURN_REGISTER_STORAGE);
// Now save the registers
for (int i = 0; i < savedRegisters.length; i++) {
if (savedRegisters[i] != null) {
assert isStackSlot(slots[i]) : "not a StackSlot: " + slots[i];
Register savedRegister = savedRegisters[i];
StackSlot slot = asStackSlot(slots[i]);
SPARCAddress slotAddress = (SPARCAddress) crb.asAddress(slot);
RegisterValue input = savedRegister.asValue(slot.getValueKind());
SPARCMove.emitStore(input, slotAddress, slot.getPlatformKind(), DUMMY, null, crb, masm);
}
}
}
Aggregations