use of com.oracle.truffle.api.frame.FrameDescriptor in project sulong by graalvm.
the class LazyToTruffleConverterImpl method convert.
@Override
public RootCallTarget convert() {
CompilerAsserts.neverPartOfCompilation();
// parse the function block
parser.parse(diProcessor, source);
// prepare the phis
final Map<InstructionBlock, List<Phi>> phis = LLVMPhiManager.getPhis(method);
// setup the frameDescriptor
final FrameDescriptor frame = StackManager.createFrame(method);
LLVMLivenessAnalysisResult liveness = LLVMLivenessAnalysis.computeLiveness(frame, context, phis, method);
LLVMSymbolReadResolver symbols = new LLVMSymbolReadResolver(runtime, frame);
List<FrameSlot> notNullable = new ArrayList<>();
LLVMRuntimeDebugInformation dbgInfoHandler = new LLVMRuntimeDebugInformation(frame, nodeFactory, context, notNullable, symbols, runtime);
dbgInfoHandler.registerStaticDebugSymbols(method);
LLVMBitcodeFunctionVisitor visitor = new LLVMBitcodeFunctionVisitor(runtime, frame, phis, nodeFactory, method.getParameters().size(), symbols, method, liveness, notNullable, dbgInfoHandler);
method.accept(visitor);
FrameSlot[][] nullableBeforeBlock = getNullableFrameSlots(frame, liveness.getNullableBeforeBlock(), notNullable);
FrameSlot[][] nullableAfterBlock = getNullableFrameSlots(frame, liveness.getNullableAfterBlock(), notNullable);
LLVMSourceLocation location = method.getLexicalScope();
List<LLVMExpressionNode> copyArgumentsToFrame = copyArgumentsToFrame(frame);
LLVMExpressionNode[] copyArgumentsToFrameArray = copyArgumentsToFrame.toArray(new LLVMExpressionNode[copyArgumentsToFrame.size()]);
LLVMExpressionNode body = nodeFactory.createFunctionBlockNode(runtime, frame.findFrameSlot(LLVMException.FRAME_SLOT_ID), visitor.getBlocks(), nullableBeforeBlock, nullableAfterBlock, location, copyArgumentsToFrameArray);
RootNode rootNode = nodeFactory.createFunctionStartNode(runtime, body, method.getSourceSection(), frame, method, source, location);
return Truffle.getRuntime().createCallTarget(rootNode);
}
use of com.oracle.truffle.api.frame.FrameDescriptor in project sulong by graalvm.
the class StackManager method createRootFrame.
public static FrameDescriptor createRootFrame() {
final FrameDescriptor rootFrame = new FrameDescriptor();
rootFrame.addFrameSlot(LLVMStack.FRAME_ID, PointerType.VOID, FrameSlotKind.Object);
return rootFrame;
}
use of com.oracle.truffle.api.frame.FrameDescriptor in project sulong by graalvm.
the class StackManager method createFrame.
public static FrameDescriptor createFrame(FunctionDefinition function) {
final FrameDescriptor frame = new FrameDescriptor();
frame.addFrameSlot(LLVMException.FRAME_SLOT_ID, null, FrameSlotKind.Object);
frame.addFrameSlot(LLVMStack.FRAME_ID, PointerType.VOID, FrameSlotKind.Object);
for (FunctionParameter parameter : function.getParameters()) {
Type type = parameter.getType();
if (parameter.isSourceVariable()) {
type = type.shallowCopy();
}
frame.addFrameSlot(parameter.getName(), type, Type.getFrameSlotKind(type));
}
final StackAllocationFunctionVisitor functionVisitor = new StackAllocationFunctionVisitor(frame);
function.accept((FunctionVisitor) functionVisitor);
return frame;
}
use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.
the class ReadOnlyArrayListPartialEvaluationTest method constantValue.
@Test
public void constantValue() {
FrameDescriptor fd = new FrameDescriptor();
AbstractTestNode result = new ReadOnlyArrayListConstantNode(42);
assertPartialEvalEquals("constant42", new RootTestNode(fd, "constantValue", result));
}
use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.
the class SimplePartialEvaluationTest method longAddConstants.
@Test
public void longAddConstants() {
FrameDescriptor fd = new FrameDescriptor();
AbstractTestNode result = new ConstantTestNode(2);
for (int i = 0; i < 20; ++i) {
result = new AddTestNode(result, new ConstantTestNode(2));
}
assertPartialEvalEquals("constant42", new RootTestNode(fd, "longAddConstants", result));
}
Aggregations