use of com.github.anba.es6draft.compiler.assembler.InstructionAssembler in project es6draft by anba.
the class RuntimeInfoGenerator method debugInfo.
private void debugInfo(MethodCode code, MethodName... names) {
InstructionAssembler asm = new InstructionAssembler(code);
asm.begin();
asm.anew(Types.DebugInfo, Methods.DebugInfo_init);
for (MethodName name : names) {
asm.dup();
asm.handle(name);
asm.invoke(Methods.DebugInfo_addMethod);
}
asm._return();
asm.end();
}
use of com.github.anba.es6draft.compiler.assembler.InstructionAssembler in project es6draft by anba.
the class RuntimeInfoGenerator method runtimeInfo.
void runtimeInfo(Script node) {
InstructionAssembler asm = new InstructionAssembler(codegen.newMethod(node, ScriptName.RTI));
asm.begin();
asm.aconst(node.getSource().getName());
asm.aconst(node.getSource().getFileString());
asm.handle(codegen.methodDesc(node, ScriptName.Eval));
if (codegen.isEnabled(Compiler.Option.DebugInfo)) {
debugInfo(node);
asm.handle(codegen.methodDesc(node, ScriptName.DebugInfo));
asm.invoke(Methods.RTI_newScriptBodyDebug);
} else {
asm.invoke(Methods.RTI_newScriptBody);
}
asm._return();
asm.end();
}
use of com.github.anba.es6draft.compiler.assembler.InstructionAssembler in project es6draft by anba.
the class CodeGenerator method debugInfo.
private void debugInfo(MethodCode method, MethodName... names) {
InstructionAssembler asm = new InstructionAssembler(method);
asm.begin();
asm.anew(Methods.DebugInfo_new);
for (MethodName name : names) {
if (name != null) {
asm.dup();
asm.handle(name);
asm.invoke(Methods.DebugInfo_addMethod);
}
}
asm._return();
asm.end();
}
use of com.github.anba.es6draft.compiler.assembler.InstructionAssembler in project es6draft by anba.
the class RuntimeInfoGenerator method runtimeInfo.
void runtimeInfo(Module node) {
InstructionAssembler asm = new InstructionAssembler(codegen.newMethod(node, ModuleName.RTI));
asm.begin();
asm.aconst(node.getSource().getName());
asm.aconst(node.getSource().getFileString());
asm.handle(codegen.methodDesc(node, ModuleName.Init));
asm.handle(codegen.methodDesc(node, ModuleName.Code));
if (codegen.isEnabled(Compiler.Option.DebugInfo)) {
debugInfo(node);
asm.handle(codegen.methodDesc(node, ModuleName.DebugInfo));
asm.invoke(Methods.RTI_newModuleBodyDebug);
} else {
asm.invoke(Methods.RTI_newModuleBody);
}
asm._return();
asm.end();
}
use of com.github.anba.es6draft.compiler.assembler.InstructionAssembler in project es6draft by anba.
the class RuntimeInfoGenerator method runtimeInfo.
private <T extends Node> void runtimeInfo(T def, FunctionNode node, boolean tailCall, boolean tailConstruct, String source, int sourceSplit, BiConsumer<T, FunctionName> debugInfo) {
FunctionName constructName = tailConstruct ? FunctionName.ConstructTailCall : FunctionName.Construct;
InstructionAssembler asm = new InstructionAssembler(codegen.newMethod(node, FunctionName.RTI));
asm.begin();
asm.invokedynamic("methodInfo", Type.methodType(Types.Object), RUNTIME_INFO_BOOTSTRAP);
asm.aconst(node.getFunctionName());
asm.iconst(functionFlags(node, tailCall, tailConstruct));
asm.iconst(ExpectedArgumentCount(node.getParameters()));
if (hasMappedOrLegacyArguments(node)) {
// TODO: Make this a compact string (to save bytecode and memory size)?
newStringArray(asm, mappedNames(node.getParameters()));
} else {
asm.anull();
}
asm.aconst(source);
asm.iconst(sourceSplit);
if (node.isAsync() || node.isGenerator()) {
asm.handle(codegen.methodDesc(node, FunctionName.Code));
} else {
asm.anull();
}
asm.handle(codegen.methodDesc(node, FunctionName.Call));
if (node.isConstructor()) {
asm.handle(codegen.methodDesc(node, constructName));
} else {
asm.anull();
}
if (codegen.isEnabled(Compiler.Option.DebugInfo)) {
debugInfo.accept(def, constructName);
asm.handle(codegen.methodDesc(node, FunctionName.DebugInfo));
asm.invoke(Methods.RTI_newFunctionDebug);
} else {
asm.invoke(Methods.RTI_newFunction);
}
asm._return();
asm.end();
}
Aggregations